/**
 * Created by zheng on 2018/8/6.
 */

export default class Point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  getDistance(point1, point2) {
    if (this.isPoint(point1) && this.isPoint(point2)) {
      return Math.sqrt(point1 * point1 + point2 * point2);
    }
  }

  getHorDistance(point1, point2) {
    if (this.isPoint(point1) && this.isPoint(point2)) {
      return Math.sqrt(point1.x - point2.x)
    }
  }

  getVerDistance(point1, point2) {
    if (this.isPoint(point1) && this.isPoint(point2)) {
      return Math.sqrt(point1.y - point2.y)
    }
  }

  isPoint(point) {
    return {}.toString.call(point1) == "[object Point]"
  }
}
